pp108 : Date and Time Functions of Rule Engine

Date and Time Functions of Rule Engine

This topic describes the various date and time functions available in the rule engine function library.


Date and time functions are used to manipulate the date and time data of a business object.

The following date-time functions are used to parse a string to a date:

  • YYYY-MM-DD
    T HH:MI:SS
  • YYYY/MM/DD
    T HH:MI:SS

    Note:
  • If you do not specify any arguments, the function is processed based on the present date and time.
  • If you specify a value that is out of the acceptable range, the function returns -1.

    The following table describes the elements in the date-time format.

    Table 1. Elements in Date-Time Format
    Element Description
    YYYY Year
    MM Month
    DD Day
    T Delimiter to separate the date and time
    HH Hours
    MI Minutes
    SS Seconds


    The following table describes the date and time functions, and their usage.

    Table 2. Rule Engine Date and Time Functions
    Date Functions Syntax Parameters
    dateReturns the number of days from the first of January 1 A.D. to the date you specified. date(year, month, day)


    • yearshould be an integer that can be greater than or equal to 1.
    • monthshould be an integer that is between 1 (representing January) and 12 (representing December).
    • dayshould be an integer between 1 and 31.
      Example:date(2007,06,22)If date is given without parameters, it takes the current date as the parameter.
    date(e)

    e is a string expression that should contain the date in the expected date-time format.Example:date("2007-06-22T00:00:00")

    utcReturns the number of seconds that elapsed from January 1, 1970, 00:00:00, Universal Coordinated Time to the specified date. utc(year, month, day, hours, minutes, seconds)


    • For
      year specify the full year to ensure cross-century accuracy. If you represent a year with a number between 0 and 99, then the year would be 1900 + year.
    • month should be an integer that is between 1 (representing January) and 12 (representing December).
    • day should be an integer between 1 and 31.
    • T represents the delimiter to separate the date and time.
    • hour should be an integer that can be between 0 (representing midnight) and 23 (representing 11 p.m.).
    • minute should be an integer between 0 and 59.
    • second should be an integer between 0 and 59.
      Example:utc(2007,06,22,11,46,10)
    utc(e)

    e is a string expression that should contain the date in the expected date-time format.Example:utc("2007-06-22T11:46:10")

    utcgmtReturns the number of seconds that elapsed from January 1, 1970, 00:00:00, Universal Coordinated Time to the current GMT. ustgmt() - does not take any parameters as arguments. Example: The value returned byutcgmt()when the date and time values are
    2007-06-22 and
    01:51:27 respectively is
    1280285487 seconds.


    To customize the date format such that the output (date) is derived in different numeric and text formats you can use sprintf functions. For more information on sprintf functions, refer to Sprintf Functions for Formatting Dates.

    To customize the time format such that the time is displayed in either the 12-hr format or the 24-hr format, refer to Sprintf Function for Formatting Time